package com.speaktoitcookbook.util;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

/**
 * 日志
 * 
 * @author 杨 强
 * 
 */
public class LogUtil {
    private static final Logger LOG = Logger.getRootLogger();
    private static PatternLayout p = new PatternLayout(
            "[SpeaktoitCookbookWeb][%p][%d{yyyy-MM-dd HH:mm:ss}]:%m%n");
    private static ConsoleAppender appender = new ConsoleAppender(p,
            ConsoleAppender.SYSTEM_OUT);

    public static Logger getLogger(Class<?> cls) {

        Logger log = LOG;
        if (cls != null) {
            log = Logger.getLogger(cls);
        }
        log.addAppender(appender);
        return log;
    }

    public static Logger getLogger() {
        return LOG;
    }
}
